home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / lib / linux-boot-probes / mounted / 40grub2 < prev    next >
Text File  |  2009-09-21  |  2KB  |  93 lines

  1. #!/bin/sh
  2. . /usr/share/os-prober/common.sh
  3. set -e
  4.  
  5. partition="$1"
  6. bootpart="$2"
  7. mpoint="$3"
  8. type="$4"
  9.  
  10. found_item=0
  11.  
  12. entry_result () {
  13.     if [ "$ignore_item" = 0 ] && \
  14.        [ -n "$kernel" ] && \
  15.        [ -e "$mpoint/$kernel" ]; then
  16.         result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters"
  17.         found_item=1
  18.     fi
  19.     kernel=""
  20.     parameters=""
  21.     initrd=""
  22.     title=""
  23.     ignore_item=0
  24. }
  25.  
  26. parse_grub_menu () {
  27.     mpoint="$1"
  28.     rootpart="$2"
  29.     bootpart="$3"
  30.     
  31.     kernel=""
  32.     parameters=""
  33.     initrd=""
  34.     title=""
  35.     ignore_item=0
  36.  
  37.     while read line; do
  38.         debug "parsing: $line"
  39.         set -- $line
  40.         case "$1" in
  41.             menuentry)
  42.                 entry_result
  43.                 shift 1
  44.                 # The double-quoted string is the title.
  45.                 title="$(echo $@ | sed 's/.*"\(.*\)".*/\1/' | sed 's/://g')"
  46.                 if echo "$title" | grep -q '(on /dev/[^)]*)$'; then
  47.                     log "Skipping entry '$title':"
  48.                     log "appears to be an automatic reference taken from another menu.lst"
  49.                     ignore_item=1
  50.                 fi
  51.             ;;
  52.             linux)
  53.                 # Hack alert: sed off any (hdn,n) but
  54.                 # assume the kernel is on the same
  55.                 # partition.
  56.                 kernel="$(echo $2 | sed 's/(.*)//')"
  57.                 shift 2
  58.                 parameters="$@"
  59.                 # Systems with a separate /boot will not have
  60.                 # the path to the kernel in grub.cfg.
  61.                 if [ "$partition" != "$bootpart" ]; then
  62.                     kernel="/boot$kernel"
  63.                 fi
  64.             ;;
  65.             initrd)
  66.                 initrd="$(echo $2 | sed 's/(.*)//')"
  67.                 # Initrd same.
  68.                 if [ "$partition" != "$bootpart" ]; then
  69.                     initrd="/boot$initrd"
  70.                 fi
  71.             ;;
  72.             "}")
  73.                 entry_result
  74.             ;;
  75.         esac
  76.     done
  77.  
  78.     entry_result
  79. }
  80.  
  81. if [ -e "$mpoint/boot/grub/grub.cfg" ] && \
  82.    ([ ! -e "$mpoint/boot/grub/menu.lst" ] || \
  83.     [ "$mpoint/boot/grub/grub.cfg" -nt "$mpoint/boot/grub/menu.lst" ]); then
  84.     debug "parsing grub.cfg"
  85.     parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/grub.cfg"
  86. fi
  87.  
  88. if [ "$found_item" = 0 ]; then
  89.     exit 1
  90. else
  91.     exit 0
  92. fi
  93.